/**
 *    @file       baseconf.h
 *
 *    @brief      
 *    @details
 *
 *    @version    1.0
 *    @date       02/16/2014 10:39:09 AM
 *
 *    @author     Theophilus (), wangtf418@gmail.com 
 */
#ifndef _SF_BASECONF_H_
#define _SF_BASECONF_H_
#include "srvdef.h"
#include "ini_config.h"

template<typename _Tconf>
class confmgr : public ini_config
{
public:
	confmgr() {}
	confmgr(const std::string &conf_filename) : ini_config(conf_filename) {}
	virtual ~confmgr() {}

public:
	virtual bf_int_t read_conf()
	{
		bf_int_t ret = init();
		if (ret != BF_OK)
		{
			return BF_ERROR;
		}
		return read_conf_items();
	}

public:
	_Tconf & get_conf() {return m_conf;}

protected:
	virtual bf_int_t read_conf_items() = 0;

protected:
	_Tconf m_conf;
};

struct baseconf_item
{
	bf_uint_t m_srvip;
	bf_ushort_t m_srvport;
	bf_uint_t m_maintain_ip;
	bf_ushort_t m_maintain_port;

	bf_uint_t m_max_fd_size;
	bf_time_t m_sockettask_timeout;
	bf_time_t m_lsockettask_timeout;

	bf_uint32_t m_netio_thdnum;
	bf_uint32_t m_proc_thdnum;
	bf_uint32_t m_db_thdnum;
	bf_uint32_t m_file_thdnum;
	bf_uint32_t m_client_thdnum;
};

class baseconf : public confmgr<baseconf_item>
{
public:
	baseconf();
	virtual ~baseconf();

protected:
	virtual bf_int_t read_conf_items();
};

#endif

